package me.notfirecodes.suicidehunt;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class EndHuntCMD implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (sender instanceof Player){
            Player player = (Player) sender;
            if(player.hasPermission("suicidehunt.end")){
                player.getInventory().clear();
                player.setInvulnerable(false);
                player.setHealth(20);
                player.setFoodLevel(20);
                player.setSaturation(10);
                Bukkit.broadcastMessage(ChatColor.GREEN + "The hunt is over!");
            }else{
                player.sendMessage(ChatColor.RED + "You do not have permission to run this command.");
            }
        }else{
            System.out.println(ChatColor.RED + "You cannot run this command with console!");
        }
        return true;
    }
}
